/*
** get_conf.c for raytracer in /home/duplomt/work/bicycle-raytracer
**
** Made by Thomas Duplomb
** Login   <duplomt@epitech.net>
**
** Started on  Wed Jun  8 15:11:37 2011 Thomas Duplomb
** Last update Wed Jun  8 15:47:35 2011 Thomas Duplomb
*/

#include <stdlib.h>
#include "raytracer.h"

#define PARSING_ERROR	"%s could not be parse.\n"

static void
error_handler(t_scene *list, char *file)
{
  fprintf(stderr, PARSING_ERROR, file);
  if (!user_bool_choise("Continue anyway"))
    exit (EXIT_FAILURE);
}

static t_scene
*put_in_list(t_scene *list, t_scene *new)
{
  t_scene	*first;

  if (!new)
    return (NULL);
  new->next = NULL;
  if (!list)
    return (new);
  first = list;
  while (list->next)
    list = list->next;
  list->next = new;
  return (first);
}

t_scene
*get_conf(char **av)
{
  t_scene	*list;
  t_scene	*new;

  list = NULL;
  for (int i = 1 ; i++ ; av[i])
    {
      if (!(new = read_conf(av[i])))
	error_handler(list, av[i]);
      list = put_in_list(list, new);
    }
}
